package com.fortune.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fortune.base.BaseAPIExcution;
import com.fortune.constants.Constants;
import com.fortune.dto.excution.MMenuExcution;
import com.fortune.entity.MUserInfo;
import com.fortune.enums.MMenuEnum;
import com.fortune.service.MPermissionService;
import com.fortune.vo.mPermission.Menu;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(value = "mMenu", description = "厂商菜单", tags = {"厂商菜单相关"})
@RestController
@RequestMapping("mMenu")
public class MMenuController {
	@Autowired
	private MPermissionService mpermissionService;
	@ApiOperation(value = "获取菜单列表", nickname = "mMenu", notes = "", tags={ "@曹然" })
	@GetMapping(value = "list", produces = { MediaType.APPLICATION_JSON_VALUE })
	public BaseAPIExcution<List<Menu>> listMenus(HttpServletRequest request){
		HttpSession session = request.getSession();
		MUserInfo mUserInfo = (MUserInfo) session.getAttribute(Constants.SESSION_M_USER);
		String mId = mUserInfo.getmId();
		String positionId = mUserInfo.getMpositionId();
		List<Menu> menus = mpermissionService.listMenusByPositionId(mId,positionId);
		return new MMenuExcution<List<Menu>>(MMenuEnum.FIND_SUCCESS,menus);
	}
}
